let sjNum = Math.floor(Math.random() *100) + 1
const span = document.getElementsByTagName("span")
const p = document.getElementsByTagName('p')
let i = 0
function srNumber(){
    let srNum = document.getElementById('srNum').value
    if(srNum<=100 && srNum>=1){
        span[0].innerHTML = srNum
        i = i + 1
        pdNumber(srNum,i)  
    }
    else{
        p[3].innerHTML = "请输入1到100之间的整数"
    }
}
function pdNumber(srNum,i){
    if(srNum == sjNum){
        p[3].innerHTML = "恭喜你猜对了，你猜了"+i+"次"
    }
    else if(srNum < sjNum){
        p[3].innerHTML = "你猜了数太小了，你猜了"+i+"次"
        if(i == 10){
            p[3].innerHTML = "你猜了"+i+"次没猜对，游戏结束!!"
            document.getElementsByTagName("input")[1].hidden = true
            document.getElementsByTagName("input")[0].value = '随机整数为:' + sjNum
            document.getElementsByTagName("input")[2].hidden = false
        }
        
    }
    else if(srNum > sjNum){
        p[3].innerHTML = "你猜了数太大了，你猜了"+i+"次"
        if(i == 10){
            p[3].innerHTML = "你猜了"+i+"次没猜对，游戏结束!!"
            document.getElementsByTagName("input")[1].hidden = true
            document.getElementsByTagName("input")[0].value = '随机整数为:' + sjNum
            document.getElementsByTagName("input")[2].hidden = false
        }
        
    }
    
}
function reSet() {
    document.getElementsByTagName("input")[2].hidden = true
    document.getElementsByTagName("input")[0].value = ""
    document.getElementsByTagName("input")[1].hidden = false
    i = 0
}